Skip to content

Conversation

@tzachz
Copy link
Owner

@tzachz tzachz commented Oct 25, 2021

No description provided.

for (int i = 0; i < arr.length; i++) { // expect error: for loop
System.out.println(arr[i]); // expect error: println
}
if ("1" == "1") { // expect error: use equals
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Problem: An equality operator (== or !=) is used to compare strings, which matches strings based on address.

Fix: Do content comparison using the equals() method to compare the values of the strings.

@tzachz tzachz closed this Oct 25, 2021
@tzachz tzachz reopened this Oct 25, 2021
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 3 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell C 8 Code Smells

7.7% 7.7% Coverage
0.0% 0.0% Duplication

for (int i = 0; i < arr.length; i++) { // expect error: for loop
System.out.println(arr[i]); // expect error: println
}
if ("1" == "1") { // expect error: use equals
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Use equals() to compare object references. (view)

Details
Rule Ruleset Priority
CompareObjectsWithEquals Error Prone 3

References:

You can close this issue if no need to fix it. Learn more.

// expect error: unused
private String unused() {
String[] arr = new String[] {"a", "b"};
for (int i = 0; i < arr.length; i++) { // expect error: for loop
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] This for loop can be replaced by a foreach loop (view)

Details
Rule Ruleset Priority
ForLoopCanBeForeach Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

}

// expect error: length, number of vars, unused vars, duplication, unused
private void createScheduledFetcher2(LeaderBoardServerConfiguration configuration, Environment environment, GitHubApiFacade apiFacade, LeaderBoardStore store, String aaa, String bbb, String ccc, String ddd) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid unused method parameters such as 'aaa'. (view)

Details
Rule Ruleset Priority
UnusedFormalParameter Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

}

// expect error: length, number of vars, unused vars, duplication, unused
private void createScheduledFetcher2(LeaderBoardServerConfiguration configuration, Environment environment, GitHubApiFacade apiFacade, LeaderBoardStore store, String aaa, String bbb, String ccc, String ddd) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid unused method parameters such as 'bbb'. (view)

Details
Rule Ruleset Priority
UnusedFormalParameter Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

}

// expect error: length, number of vars, unused vars, duplication, unused
private void createScheduledFetcher2(LeaderBoardServerConfiguration configuration, Environment environment, GitHubApiFacade apiFacade, LeaderBoardStore store, String aaa, String bbb, String ccc, String ddd) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid unused method parameters such as 'ccc'. (view)

Details
Rule Ruleset Priority
UnusedFormalParameter Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

}

// expect error: length, number of vars, unused vars, duplication, unused
private void createScheduledFetcher2(LeaderBoardServerConfiguration configuration, Environment environment, GitHubApiFacade apiFacade, LeaderBoardStore store, String aaa, String bbb, String ccc, String ddd) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid unused private methods such as 'createScheduledFetcher2(LeaderBoardServerConfiguration,Environment,GitHubApiFacade,LeaderBoardStore,String,String,String,String)'. (view)

Details
Rule Ruleset Priority
UnusedPrivateMethod Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

for (int i = 0; i < arr.length; i++) { // expect error: for loop
System.out.println(arr[i]); // expect error: println
}
if ("1" == "1") { // expect error: use equals
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Use equals() to compare strings instead of '==' or '!=' (view)

Details
Rule Ruleset Priority
UseEqualsToCompareStrings Error Prone 3

References:

You can close this issue if no need to fix it. Learn more.


protected GitHubApiFacade getApiFacade(LeaderBoardServerConfiguration configuration) {
// expect error: bad name
protected GitHubApiFacade GetApiFacade(LeaderBoardServerConfiguration configuration) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Checkstyle] Name 'GetApiFacade' must match pattern '^[a-z][a-zA-Z0-9]*$'. (view)

Details
Rule Severity
MethodNameCheck info

References:

You can close this issue if no need to fix it. Learn more.

}

// expect error: length, number of vars, unused vars, duplication, unused
private void createScheduledFetcher2(LeaderBoardServerConfiguration configuration, Environment environment, GitHubApiFacade apiFacade, LeaderBoardStore store, String aaa, String bbb, String ccc, String ddd) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Checkstyle] More than 7 parameters (found 8). (view)

Details
Rule Severity
ParameterNumberCheck info

References:

You can close this issue if no need to fix it. Learn more.

for (int i = 0; i < arr.length; i++) { // expect error: for loop
System.out.println(arr[i]); // expect error: println
}
if ("1" == "1") { // expect error: use equals
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Checkstyle] Literal Strings should be compared using equals(), not '=='. (view)

Details
Rule Severity
StringLiteralEqualityCheck info

References:

You can close this issue if no need to fix it. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants